<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>出车登记</title>
    <!-- Tell the browser to be responsive to screen width -->
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<!-- Vendor CSS-->
		<link href="${weiZe }/assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
		<link href="${weiZe }/assets/vendor/skycons/css/skycons.css" rel="stylesheet" />
		<link href="${weiZe }/assets/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
		<link href="${weiZe }/assets/vendor/css/pace.preloader.css" rel="stylesheet" />
		<!-- Plugins CSS-->
		<link href="${weiZe }/assets/plugins/bootkit/css/bootkit.css" rel="stylesheet" />
		<link href="${weiZe }/assets/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" />					
		<!-- Theme CSS -->
		<link href="${weiZe }/assets/page/css/index/jquery.mmenu.css" rel="stylesheet " />
		<!-- Page CSS -->		
		<link href="${weiZe }/assets/page/css/index/index.css" rel="stylesheet" />
		<link href="${weiZe }/assets/page/css/index/add-ons.min.css" rel="stylesheet" />
		<!-- end: CSS file-->	
		<!-- Head Libs -->
		<script src="${weiZe }/assets/plugins/modernizr/js/modernizr.js"></script>
	
	
	<style type="text/css">
		/*弹窗样式*/
		#maskY{
            background: #000;
            opacity: 0.75;
            /*IE兼容*/
            filter: alpha(opacity=75);
            height: 1000px;
            width: 100%;
            position: absolute;
            left: 0;
            top: 0;
            /*z-index: 1000;*/
          }
          #formDispach{
            position: fixed;
            left: 30%;
            top: 5%;
            /*z-index:1100;*/
          }
          .formCon{
            width: auto;
            height: auto;
            background: #FFF;
            position: relative;
          }
	</style>
  </head>
  
  <body class="hold-transition  sidebar-mini">
  			
  	
  
  
  
  	<%--弹窗 --%>
		<div class="tan hide" id="maskY"></div>
		<div class="tan hide" id="formDispach" style="">
			<div class="formCon" style="">
				<form:form id="inputForm" modelAttribute="tbOutCarRegister" action="${ctx}/tb_out_car_register/tbOutCarRegister/tbOutCarRegisterList/save" method="post" class="sidebar-form">
	  				<form:hidden path="id"/>
					<form:hidden id="waybillId"  path="waybillId"/>
			        <div class="input-group">
			          <div class="modal-dialog">
					  	 <div class="modal-content">
					          <div class="modal-header">
					            <button type="button" class="close" data-dismiss="modal" aria-label="Close"  >
					              <span aria-hidden="true">&times;</span></button>
					            <h4 class="modal-title">出车登记</h4>
					          </div>
					          <div class="modal-body">
					            	<section class="invoice" id="invoice_context">
					            		<div class="col-md-6">
	              							<div class="form-group">
	              							</div>
	              						</div>
					            	</section>
				            	<section class="content">
					            	<div class="box box-default">
					            		<div class="box-body">
					            			<div class="row">
					            				 	<div class="form-group">
	               										<label>领款人</label>
	             										<form:select id="moneyUser" path="moneyUser" class="form-control" style="width: 100%;">
															<form:option  value="" label=""/>
															<form:options items="${driver}" itemValue="id" itemLabel="driverName" htmlEscape="false"/>
														</form:select>
	               									</div>
	               									<div class="form-group">
	               										<label>油卡</label>
	               										<form:radiobuttons path="oilCare" items="${fns:getDictList('oil_state')}" itemLabel="label" itemValue="value" htmlEscape="false" class=" minimal"/>
	               									</div>
					            				 	<div class="form-group">
	               										<label>金额</label>
	               										<input type="text" class="form-control" path="money">
	               									</div>
	               									<div class="form-group">
	               										<label>备注</label>
	             										<form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="255" class="form-control" />
	               									</div>
					            			</div>
					            		</div>
					            	</div>
					      		 </section>
					          </div>
					          <div class="modal-footer">
					            <button type="button" class="btn btn-default pull-left closeBtn" data-dismiss="modal" >取消</button>
					            <button type="submit" class="btn btn-primary">提交</button>
					          </div>
					        </div>
				        </div>
		  			</div>
		      </form:form>
			</div>
  		</div>
  	<%--弹窗 end--%>
  
  
  
  
  
    <sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<th>序号</th>
			<th colspan="2">装货地址</th>
			<th colspan="3">卸货地址</th>
			<th colspan="3">货物</th>
			<th colspan="3">货物重量</th>
			<th>车牌号</th>
			<th>挂车号</th>
			<th >司机</th>
			<shiro:hasPermission name="tb_out_car_register:tbOutCarRegister:edit"><th>操作</th></shiro:hasPermission>
		</thead>
		<tbody>
			<c:forEach items="${page}" var="tbWaybill" varStatus="status">
				<tr>
					<td>${status.count} </td>
					<%--装货地址 --%>
					<td>${tbWaybill.tbLoadingAddress.shortName}</td>
					<td>${tbWaybill.tbLoadingAddressTwo.shortName}</td>
					<%--装货地址 end--%>
					<%--收货地址 --%>
					<td>${tbWaybill.tbWaybillDetailOne.tbDischargeCargoAddress.shortName}</td>
					<td>${tbWaybill.tbWaybillDetailTwo.tbDischargeCargoAddress.shortName}</td>
					<td>${tbWaybill.tbWaybillDetailThree.tbDischargeCargoAddress.shortName}</td>
					<%--收货地址 end--%>
					<%--品名 --%>
					<td>${tbWaybill.tbWaybillDetailOne.tbGoods.goodName}</td>
					<td>${tbWaybill.tbWaybillDetailTwo.tbGoods.goodName}</td>
					<td>${tbWaybill.tbWaybillDetailThree.tbGoods.goodName}</td>
					<%--品名 end--%>
					<%--重量 --%>
					<td>${tbWaybill.tbWaybillDetailOne.weight}</td>
					<td>${tbWaybill.tbWaybillDetailTwo.weight}</td>
					<td>${tbWaybill.tbWaybillDetailThree.weight}</td>
					<%--重量 end--%>
					<td>${tbWaybill.tbCarInfo.carCode}</td>
					<td>${tbWaybill.tbCarInfo.carGCode}</td>
					<td>${tbWaybill.tbDriver.driverName}&nbsp;|&nbsp;${tbWaybill.tbDriverTwo.driverName}</td>
					
					<shiro:hasPermission name="tb_out_car_register:tbOutCarRegister:edit"><td>
						<a href="javascript:void(0);" onclick="alertTan(this,event,'${tbWaybill.id}',
						'${tbWaybill.tbCarInfo.carCode}',
						'${tbWaybill.tbCarInfo.carGCode}',
						'${tbWaybill.tbDriver.driverName }&Iota; ${tbWaybill.tbDriverTwo.driverName}');">登记</a>
					</td></shiro:hasPermission>
				</tr>
			</c:forEach>
		</tbody>
	</table>
  </body>
<!-- Vendor JS-->				
		<script src="${weiZe }/assets/vendor/js/jquery.min.js"></script>
		<script src="${weiZe }/assets/vendor/js/jquery-2.1.1.min.js"></script>
		<script src="${weiZe }/assets/vendor/js/jquery-migrate-1.2.1.min.js"></script>
		<script src="${weiZe }/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
		<script src="${weiZe }/assets/vendor/skycons/js/skycons.js"></script>	
		<script src="${weiZe }/assets/vendor/js/pace.min.js"></script>
		
		<!-- Plugins JS-->
		<script src="${weiZe }/assets/plugins/autosize/jquery.autosize.min.js"></script>
		<script src="${weiZe }/assets/plugins/jquery-validation/js/jquery.validate.js"></script>
		<script src="${weiZe }/assets/plugins/wizard/js/jquery.bootstrap.wizard.min.js"></script>
		<script src="${weiZe }/assets/plugins/pnotify/js/pnotify.custom.js"></script>	
		<script src="${weiZe }/assets/plugins/sparkline/js/jquery.sparkline.min.js"></script>
		
		<!-- Theme JS -->		
		<script src="${weiZe }/assets/js/jquery.mmenu.min.js"></script>
		<script src="${weiZe }/assets/js/core.min.js"></script>
		
		<!-- Pages JS -->
		<script src="${weiZe }/assets/page/js/newCarlist/newCarlist.js"></script>		
		<script src="${ctxStatic }/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
		var browser = {
	        versions: function() {
	            var u = navigator.userAgent,
	            app = navigator.appVersion;
	            return {
	                mobile: !!u.match(/AppleWebKit.*Mobile.*/),
	                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
	                android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
	                iPhone: u.indexOf("iPhone") > -1,
	                iPad: u.indexOf("iPad") > -1
	            };
	        } (),
	        language: (navigator.browserLanguage || navigator.language).toLowerCase()
	    };
		
		$(document).ready(function() {
			
			$(".close,.closeBtn").click(function(){
				$("#formDispach").addClass("hide");
			    $("#maskY").addClass("hide");
			});
		
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		
			
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        
        
        
        function close(){
        	$(".tan").addClass("hide");
        }
        function getLocalTime(nS) {     
		   return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');     
		}
        /**
        * id 运单ID
        carCode 车牌号、
        carGCode 挂车号
        driverName 司机
        */
        function alertTan(obj,e,id,carCode,carGCode,driverName){
        
        	$("#waybillId").val(id);
        	$.ajax({
        		url:"${ctx}/tb_waybill/tbWaybill/dispatch/findDetailById",
        		type:"post",
        		data:{
        			id:id
        		},
        		dataType:"json",
        		success:function(data){
        			
        			var row_invoice_info_countext_Two = "";
        			var row_invoice_info_countext_Three = "";
        		
        			var weight = "";
        			var goodName =  "";
        			var tbGoodsReceiptCompany = "";
        			if(data != null && typeof(data) != "undefined"){
        				weight += data.tbWaybillDetailOne.weight+"吨";
        				goodName +=data.tbWaybillDetailOne.tbGoods.goodName;
        				tbGoodsReceiptCompany+=data.tbWaybillDetailOne.tbDischargeCargoAddress.shortName;       				       				
        				if(data.tbWaybillDetailTwo != null && typeof(data.tbWaybillDetailTwo) != "undefined"){       					
        					var weightTwo = data.tbWaybillDetailTwo.weight;;
        					var goodNameTwo =  data.tbWaybillDetailTwo.tbGoods.goodName;
        					var tbGoodsReceiptCompanyTwo =data.tbWaybillDetailTwo.tbDischargeCargoAddress.shortName;;
        				
        					row_invoice_info_countext_Two +=
	        				'<div class="col-sm-4 invoice-col">'+
						          '二、'+
						          '<address>'+
						            	'品名:'+goodNameTwo+'<br>'+
						           		'重量:'+weightTwo+'<br>'+
						           		'地址:'+tbGoodsReceiptCompanyTwo+
						          '</address>'+
					        '</div>';
        				}
        				if(data.tbWaybillDetailThree != null && typeof(data.tbWaybillDetailThree) != "undefined"){
        					var weightThree =data.tbWaybillDetailThree.weight;;
        					var goodNameThree =  data.tbWaybillDetailThree.tbGoods.goodName;
        					var tbGoodsReceiptCompanyThree = data.tbWaybillDetailThree.tbDischargeCargoAddress.shortName;
        					row_invoice_info_countext_Three +=
	        				'<div class="col-sm-4 invoice-col">'+
						          '三、'+
						          '<address>'+
						            	'品名:'+goodNameThree+'<br>'+
						           		'重量:'+weightThree+'<br>'+
						           		'地址:'+tbGoodsReceiptCompanyThree+
						          '</address>'+
					        '</div>';
        				}
        				
        				var outCarTime = data.outCarTime;
        				var row = '<div class="row">'+
								        '<div class="col-xs-12">'+
								          '<h4 class="page-header">'+
								            '<i class="fa fa-truck"></i> '+ carCode +'|'+carGCode+'| '+driverName +
								           /*  '<small class="pull-right">出车时间:'+outCarTime+'</small>'+ */
								         ' </h4>'+
								        '</div>'+
								      '</div>';
						var row_invoice_info = '<div class="row invoice-info">';
        				var row_invoice_info_end = '</div>';
        				var row_invoice_info_countext_One = ''+
        				'<div class="col-sm-4 invoice-col">'+
					          '一、'+
					          '<address>'+
					            	'品名:'+goodName+'<br>'+
					           		'重量:'+weight+'<br>'+
					           		'地址:'+tbGoodsReceiptCompany+
					          '</address>'+
				        '</div>';
				        var str = ""+
	        				row_invoice_info+
	        				row_invoice_info_countext_One+
	        				row_invoice_info_countext_Two+
	        				row_invoice_info_countext_Three+
	        				row_invoice_info_end;
        				$("#invoice_context").html(row);
        				$("#invoice_context").append(str);
        				$("#formDispach").removeClass("hide");
					    $("#maskY").removeClass("hide");
        				if(browser.versions.mobile){
					    	$("#formDispach").removeClass("hide");
					    	$("#maskY").removeClass("hide");
        					//$(".formDispach").css({"width":"100%","top":"0px","left":"0px"});
        					$(".formDispach").attr("style","width:100%;top:0px;left:0px;")
					    }
        			}
        		},
        		error:function(){}
        	});        	     	
        };      
	</script>
</html>